package com.example.nutritionmate.entity;

import javax.persistence.Embeddable;
import java.io.Serializable;
import java.util.Objects;

@Embeddable
public class MealNutritionId implements Serializable {

    private Long recordId;
    private Integer nutritionId;

    // Constructors, Getters, Setters, equals, and hashCode
    public MealNutritionId() {}

    public MealNutritionId(Long recordId, Integer nutritionId) {
        this.recordId = recordId;
        this.nutritionId = nutritionId;
    }

    // Getters and Setters


    public Long getRecordId() {
        return recordId;
    }

    public void setRecordId(Long recordId) {
        this.recordId = recordId;
    }

    public Integer getNutritionId() {
        return nutritionId;
    }

    public void setNutritionId(Integer nutritionId) {
        this.nutritionId = nutritionId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        MealNutritionId that = (MealNutritionId) o;

        if (!Objects.equals(recordId, that.recordId)) return false;
        return Objects.equals(nutritionId, that.nutritionId);
    }

    @Override
    public int hashCode() {
        int result = recordId != null ? recordId.hashCode() : 0;
        result = 31 * result + (nutritionId != null ? nutritionId.hashCode() : 0);
        return result;
    }
}
